home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PWAECJ16.ZIP / JOIN.PPS < prev    next >
Text File  |  1995-05-11  |  13KB  |  399 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; Conference Join v1.6
  3. ; 1.2 Written by Drew [PWA] / 1.5 Revised by Nemesis
  4. ; Source last updated 04-14-95
  5. ;
  6. ; Written in PPL 3.0 for PCBoard 15.2+ only.
  7. ;
  8. ; Description: Generates a "menu" of conferences a user can join.  If a user
  9. ; does not have access to a conference, that conference never shows up in the
  10. ; list. :)
  11. ;
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13. ; procedure & function declarations
  14. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  15. declare procedure Initialize()
  16. declare procedure Lightbar()
  17. declare procedure PrintConfs()
  18. declare procedure ShowHeader()
  19. declare function BuildConfInfo(int i, word recsize) integer
  20. declare procedure PrintLineForConf(int i, string shortname, int offset)
  21. declare procedure ShowFooter()
  22. declare procedure RestoreOldConf()
  23.  
  24. *$USEFUNCS
  25.  
  26. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  27. ; global variables
  28. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  29. string cnames@        ; cnames.@@@
  30. string cnamesa        ; cnames.add
  31. string pattern        ; line to print for conferences
  32. string lbprompt       ; prompt to print for lightbar options
  33. string hilightcolor   ; color code to use for lightbar
  34. integer cur            ; current conference being printed by PrintConf
  35. integer startline     ; Y position of first conference on screen
  36. integer numtoprint    ; max numb of conf's to print per screen
  37. integer oldconf       ; stores user's conf num prior to running this ppe
  38. integer printed       ; stores number of lines printed on current page
  39. word recordsize
  40.  
  41.  
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  43. ; main body of program
  44. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  45. begin
  46.     Initialize()
  47.     PrintConfs()
  48.     RestoreOldConf()
  49. end
  50.  
  51.  
  52.  
  53. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  54. ; restores to the user's previous conference before running this ppe
  55. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  56. procedure RestoreOldConf()
  57.     lastin oldconf
  58. endproc
  59.  
  60.  
  61. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  62. ; Lightbar for Conference Selection
  63. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  64. procedure Lightbar()
  65.     string response,saveline
  66.     string Shortname
  67.     int optnum
  68.     int TempCur
  69.     int Reqlev
  70.     boolean PubConf
  71.     boolean done
  72.  
  73.     print lbprompt
  74.     optnum = 1
  75.     done = false
  76.     while (!done) do
  77.  
  78.        saveline = scrtext(1,optnum+startline,79,true)
  79.        ansipos 1,optnum + Startline
  80.        print hilightcolor+scrtext(1,optnum+startline,79,false)+"@X01"
  81.        ansipos 1,optnum + Startline
  82.        response = ""
  83.        
  84.        while (!done) do
  85.           response = upper(inkey())
  86.           select case (response)
  87.              case "9","3","S","X","8","2","A","Z","Q","M",CHR(13), \
  88.                   "UP","DOWN","PGUP","PGDN", "LEFT", "RIGHT", "4", "6", \
  89.                   chr(27)
  90.                 done=true
  91.           end select
  92.        end while
  93.        done = false
  94.  
  95.        select case (response)
  96.           case "A","UP","8"
  97.              ansipos 1,optnum + startline
  98.              print saveline
  99.              optnum = optnum - 1
  100.              if (optnum = 0) optnum = printed
  101.           case "Z","DOWN","2"
  102.              ansipos 1,optnum + startline
  103.              print saveline
  104.              optnum = optnum + 1
  105.              if (optnum = printed + 1) then
  106.                if (printed = numtoprint) done = true
  107.                optnum=1
  108.              endif
  109.           case "PGDN","3","X", "6", "RIGHT"
  110.             done = true
  111.             ansipos 1 , printed + startline + 1
  112.           case "PGUP","9","S", "4", "LEFT"
  113.             TempCur = S2I(Left(scrtext(1,1+startline,79,false),4),10) - 1
  114.             Printed = 0
  115.             While ((TempCur > -1) & (Printed < NumtoPrint)) do
  116.              Fseek 1, Recordsize * TempCur + 2, Seek_Set
  117.              fread 1, shortname, 14
  118.              if (strip(shortname, " ") != "") then
  119.              fread 1, pubconf, 1
  120.              if (pubconf = TRUE) then
  121.                fseek 1, 5, seek_cur
  122.                fread 1, reqlev, 2
  123.                if (u_sec >= reqlev) then
  124.                 Printed = Printed + 1
  125.                end if
  126.              end if
  127.              end if
  128.              TempCur = TempCur - 1
  129.             end while
  130.             Cur = TempCur
  131.             Done = true
  132.           case "M"
  133.              RestoreOldConf()
  134.              ansipos 1, u_pagelen
  135.              stop
  136.           case "Q", chr(27)
  137.               RestoreOldConf()
  138.               ansipos 1, u_pagelen
  139.               kbdstuff chr(13)
  140.               end
  141.           case chr(13)
  142.              if (optnum < printed + 1) then
  143.               kbdstuff Left(scrtext(1,optnum + startline,79,false),4)+chr(13)
  144.               ansipos 1, u_pagelen
  145.               stop
  146.              else
  147.               done = true
  148.              endif
  149.     end select
  150.  
  151.     end while
  152.  
  153. endproc
  154.  
  155.  
  156. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  157. ; Prints the conferences
  158. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  159. procedure PrintConfs()
  160.     int i
  161.  
  162.     getuser
  163.  
  164.     printed = 0
  165.     fopen 1, cnames@, o_rd, s_dn
  166.     fopen 2, cnamesa, o_rd, s_dn
  167.  
  168.     fread 1, recordsize, 2
  169.  
  170.     ShowHeader()
  171.     startline = gety() - 1
  172.     Cur = 0
  173.     While (Cur <= hiconfnum()) do
  174.         printed = printed + BuildConfInfo(Cur, recordsize)
  175.         if ((printed == numtoprint) | ((Cur=hiconfnum()) && printed) ) then
  176.           ShowFooter()
  177.           LightBar()
  178.           printed = 0
  179.           ShowHeader()
  180.         endif
  181.         Cur = Cur + 1
  182.     end while
  183.  
  184.     fclose 1
  185.     fclose 2
  186. endproc
  187.  
  188.  
  189. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  190. ; checks whether or not to print the current conference.  returns 1 (true)
  191. ; if the conference is available to the user, 0 (false) if not.
  192. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  193. function BuildConfInfo(int confnum, word recordsize) integer
  194.     boolean pubconf
  195.     string shortname
  196.     int reqlev, offset
  197.  
  198.     fseek 1, recordsize * Cur+2, Seek_Set
  199.     fread 1, shortname, 14
  200.  
  201.     ; first check if the conference even has a name or not.  if it
  202.     ; has no name, then it doesn't exist
  203.     ;
  204.     if (strip(shortname, " ") != "") then
  205.         ; check if it's a public conference.  if so, then check sec lev;
  206.         ; otherwise it's private, so check if user is reg'ed in the conf
  207.         ;
  208.         fread 1, pubconf, 1
  209.         if (pubconf = TRUE) then
  210.             fseek 1, 5, seek_cur
  211.             fread 1, reqlev, 2
  212.  
  213.             ; check sec level
  214.             if (u_sec >= reqlev) then
  215.                 PrintLineForConf(confnum, shortname, 0)
  216.                 BuildConfInfo = 1
  217.             else
  218.                 fseek 1, recordsize - 22, seek_cur
  219.                 BuildConfInfo = 0
  220.             endif
  221.         else
  222.             if (confreg(confnum)) then
  223.                 PrintLineForConf(confnum, shortname, 7)
  224.                 BuildConfInfo = 1
  225.             else
  226.                 fseek 1, (recordsize - 14) - 1, seek_cur
  227.                 BuildConfInfo = 0
  228.             endif
  229.         endif
  230.     else
  231.         ; if we're here, then it's a "blank" conference, so skip to the
  232.         ; next conference.  (recordsize - 14) is the conf record size minus
  233.         ; the conf name (since we've already read the name).
  234.         ;
  235.         fseek 1, recordsize - 14, seek_cur
  236.         BuildConfInfo = 0
  237.     endif
  238. endfunc
  239.  
  240.  
  241. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  242. ; prints a line for the current conference.  "offset" here can be of two
  243. ; values: 0 or 7.  0 indicates we've already read the required security
  244. ; level of a conference, 7 indicates we haven't.  we jump forward this many
  245. ; bytes to start getting the other information (msgs, doors, etc)
  246. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  247. procedure PrintLineForConf(int confnum, string shortname, int offset)
  248.     string newpattern, tmpstr1
  249.  
  250.     lastin confnum
  251.     newpattern = pattern
  252.  
  253.     ; conference number
  254.     ;
  255.     newpattern = replacestr(newpattern, "%N%", string(confnum))
  256.  
  257.     ; gets the long name from cnamesa.  this is a somewhat retarded way to do
  258.     ; it since for long names, only characters after the 14th character are
  259.     ; stored in cnames.add.  the first 14 characters are from pcb 15.1, where
  260.     ; it's still stored in cnames.@@@.  hence, we pass in the first 14 chars
  261.     ; as a parameter since we read it already, then we grab whatever is left
  262.     ; from cnames.add and concatenate the two.  this "method" is from
  263.     ; cnfn.pps, clark dev's own ppe used on salt air.
  264.     ;
  265.     fseek 2, confnum * 256 + 208, SEEK_SET
  266.     fread 2, tmpstr1, 48
  267.     tmpstr1 = shortname + tmpstr1
  268.     newpattern = replacestr(newpattern, "%C%", string(tmpstr1))
  269.  
  270.     ; msgs file
  271.     ;
  272.     fseek 1, offset + 5, seek_cur
  273.     fread 1, tmpstr1, 32
  274.     if (tmpstr1 == "") then
  275.         newpattern = replacestr(newpattern, "%M%", "No")
  276.     else
  277.         newpattern = replacestr(newpattern, "%M%", "Yes")
  278.     endif
  279.  
  280.     ; doors.lst
  281.     ; 96 + 30 + 27 + 29 + 26 + 29 = 237
  282.     ;
  283.     fseek 1, 237, seek_cur
  284.     fread 1, tmpstr1, 33
  285.     if (tmpstr1 == "") then
  286.         newpattern = replacestr(newpattern, "%D%", "No")
  287.     else
  288.         newpattern = replacestr(newpattern, "%D%", "Yes")
  289.     endif
  290.  
  291.     ; blt.lst
  292.     ;
  293.     fseek 1, 29, seek_cur
  294.     fread 1, tmpstr1, 33
  295.     if (tmpstr1 == "") then
  296.         newpattern = replacestr(newpattern, "%B%", "No")
  297.     else
  298.         newpattern = replacestr(newpattern, "%B%", "Yes")
  299.     endif
  300.  
  301.     ; script.lst
  302.     ;
  303.     fseek 1, 29, seek_cur
  304.     fread 1, tmpstr1, 33
  305.     if (tmpstr1 == "") then
  306.         newpattern = replacestr(newpattern, "%S%", "No")
  307.     else
  308.         newpattern = replacestr(newpattern, "%S%", "Yes")
  309.     endif
  310.  
  311.     ; dir.lst for file directories existence
  312.     ;
  313.     fseek 1, 62, seek_cur
  314.     fread 1, tmpstr1, 33
  315.     if (tmpstr1 == "") then
  316.         newpattern = replacestr(newpattern, "%F%", "No")
  317.     else
  318.         newpattern = replacestr(newpattern, "%F%", "Yes")
  319.     endif
  320.  
  321.     ; high message number
  322.     ;
  323.     if (instr(newpattern, "%HM%")) then
  324.         newpattern = replacestr(newpattern, "%HM%", himsgnum())
  325.     endif
  326.  
  327.     ; last message number read
  328.     ;
  329.     if (instr(newpattern, "%LR%")) then
  330.         newpattern = replacestr(newpattern, "%LR%", u_lmr(confnum))
  331.     endif
  332.  
  333.     lastin oldconf
  334.     println newpattern
  335. endproc
  336.  
  337.  
  338.  
  339. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  340. ; shows the footer file
  341. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  342. procedure ShowFooter()
  343.     if (exist(ppepath() + "JOIN.BOT")) then
  344.         dispfile ppepath() + "JOIN.BOT", DEFS
  345.     endif
  346. endproc
  347.  
  348.  
  349. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  350. ; shows the header file
  351. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  352. procedure ShowHeader()
  353.     if (exist(ppepath() + "JOIN.TOP")) then
  354.         dispstr "%" + ppepath() + "JOIN.TOP"
  355.     endif
  356. endproc
  357.  
  358.  
  359.  
  360. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  361. ; initialize
  362. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  363. procedure Initialize()
  364.     wrunet pcbnode(), "Q", un_name(), un_city(), "ECJ: Viewing confs", " "
  365.  
  366.     if (exist(ppepath() + "JOIN.CFG")) then
  367.         cnames@ = readline(pcbdat(), 31) + ".@@@"
  368.         if (!exist(cnames@)) then
  369.             println cnames@ + " does not exist.  Bad path in PCBOARD.DAT"
  370.             end
  371.         endif
  372.  
  373.         cnamesa = readline(pcbdat(), 31) + ".ADD"
  374.         if (!exist(cnamesa)) then
  375.             println cnamesa + " does not exist.  Bad path in PCBOARD.DAT"
  376.             end
  377.         endif
  378.     else
  379.         println ppepath() + "JOIN.CFG does not exist!  Exiting."
  380.         end
  381.     endif
  382.  
  383.     numtoprint = s2i(readline(ppepath() + "JOIN.CFG", 1), 10)
  384.  
  385.     pattern = readline(ppepath() + "JOIN.CFG", 2)
  386.  
  387.     lbprompt = readline(ppepath() + "JOIN.CFG", 3)
  388.  
  389.     hilightcolor = readline(ppepath() + "JOIN.CFG", 4)
  390.  
  391.     fclose -1
  392.  
  393.     ; we need to store the user's conf num they were in prior to this ppe
  394.     ; since we use "lastin" to change the active conf num in order to find
  395.     ; out the number of msgs per conf.
  396.     ;
  397.     oldconf = curconf()
  398. endproc
  399.